home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 508 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
  2. Message-ID: <4g11oe$b2d@mulga.cs.mu.OZ.AU>
  3. X-Original-Date: 16 Feb 1996 04:38:38 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 16 Feb 96 04:39:50 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Legal C++ code?
  9. Organization: Comp Sci, University of Melbourne
  10. References: <4fvtk3$16j@cnn.Princeton.EDU>
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMSQKpOEDnX0m9pzZAQEjjgF/XRhQ70WrurXQyPGZuuAL5FHUVWy2lnUl
  13.     hNy+CemtNXGLe1hytek0SOAVyD1pklJw
  14.     =v+fV
  15.  
  16. tim@franck.Princeton.EDU (Tim Hollebeek) writes:
  17.  
  18. >Is the following legal C++ code?  g++ compiles it, but it doesn't link
  19. >(undefined function Foo::foo()). 
  20.  
  21. No, the following code is not legal, because you don't have a definition
  22. for the pure virtual function Foo::foo().  But if you add one, e.g.
  23.  
  24.     int Foo::foo() { return 42; }
  25.  
  26. then the code is quite legal.
  27.  
  28. >I'm suprised it compiles at all:
  29.  
  30. It has always been legal in C++ to provide a definition for pure
  31. virtual functions, although the only way to invoke such a function is
  32. by using an explicit qualification.
  33.  
  34. Yes, this suprised me too ;-)  I think it would have been simpler to
  35. disallow definitions of pure virtual functions.
  36.  
  37. --
  38. Fergus Henderson                 WWW: http://www.cs.mu.oz.au/~fjh
  39. fjh@cs.mu.oz.au                  PGP: finger fjh@128.250.37.3
  40. ---
  41. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  42.   Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  43.   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  44.